<!--

    Copyright 2020 StreamSets Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!doctype html>
<html lang="en">
<head>
  <title>StreamSets Login</title>
</head>
<body>
  <script>
    // DO a POST to /rest/v1/alogin using the query string parameters sent to this page
    const parameters = new URL(window.location).searchParams;
    const form = document.createElement('form');
    form.style.visibility = 'hidden'; // no user interaction is necessary
    form.method = 'POST'; // forms by default use GET query strings
    form.action = '/rest/v1/alogin';
    for (const [key, value] of parameters) {
      const input = document.createElement('input');
      input.name = key;
      input.value = value;
      form.appendChild(input); // add key/value pair to form
    }
    document.body.appendChild(form); // forms cannot be submitted outside of body
    form.submit(); // send the payload and navigate
  </script>
</body>
</html>
